import { MockMethod } from "vite-plugin-mock";

export default [
	{
		url: "/api/hello_world",
		method: "get",
		response: (request) => {
			return {
				msg: "hello world",
				headers: request.headers
			};
		}
	},
	{
		url: "/api/v1/auth/captcha",
		method: "get",
		response: () => {
			return {
				code: "00000",
				data: {
					captchaKey: "534b8ef2b0a24121bec76391ddd159f9",
					captchaBase64:
						""
				},
				msg: "一切ok"
			};
		}
	},
	{
		url: "/api/v1/auth/login",
		method: "post",
		response: () => {
			return {
				code: "00000",
				data: {
					accessToken:
						"eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZG1pbiIsImp0aSI6IjE2YWJkNTlkOTAxNzQwZDliYmI3ZjczODBhZDkyNzNhIiwidXNlcklkIjoyLCJ1c2VybmFtZSI6ImFkbWluIiwiZGVwdElkIjoxLCJkYXRhU2NvcGUiOjEsImF1dGhvcml0aWVzIjpbIlJPTEVfQURNSU4iXSwiZXhwIjoxNjkxMTAzMzgyfQ.P4cuIfmPepl3HuguhMS7NXn5a7IUPpsLbmtA_rHOhHk",
					tokenType: "Bearer",
					refreshToken: null,
					expires: null
				},
				msg: "一切ok"
			};
		}
	},
	{
		url: "/api/v1/users/me",
		method: "get",
		response: () => {
			return {
				code: "00000",
				data: {
					userId: 2,
					nickname: "系统管理员",
					avatar:
						"https://oss.youlai.tech/youlai-boot/2023/05/16/811270ef31f548af9cffc026dfc3777b.gif",
					roles: ["ADMIN"],
					perms: [
						"sys:menu:delete",
						"sys:dept:edit",
						"sys:dict_type:add",
						"sys:dict:edit",
						"sys:dict:delete",
						"sys:dict_type:edit",
						"sys:menu:add",
						"sys:user:add",
						"sys:role:edit",
						"sys:dept:delete",
						"sys:user:edit",
						"sys:user:delete",
						"sys:user:reset_pwd",
						"sys:dept:add",
						"sys:role:delete",
						"sys:dict_type:delete",
						"sys:menu:edit",
						"sys:dict:add",
						"sys:role:add"
					]
				},
				msg: "一切ok"
			};
		}
	},
	{
		url: "/api/v1/auth/logout",
		method: "delete",
		response: () => {
			return {
				code: "00000",
				data: {},
				msg: "string"
			};
		}
	},
	{
		url: "/api/v1/users/page",
		method: "get",
		response: () => {
			return {
				code: "00000",
				data: {
					list: [
						{
							id: 2,
							username: "admin",
							nickname: "系统管理员",
							mobile: "17621210366",
							genderLabel: "男",
							avatar:
								"https://oss.youlai.tech/youlai-boot/2023/05/16/811270ef31f548af9cffc026dfc3777b.gif",
							email: null,
							status: 1,
							deptName: "有来技术",
							roleNames: "系统管理员",
							createTime: "2019-10-10"
						},
						{
							id: 3,
							username: "test",
							nickname: "测试小用户",
							mobile: "17621210366",
							genderLabel: "男",
							avatar:
								"https://oss.youlai.tech/youlai-boot/2023/05/16/811270ef31f548af9cffc026dfc3777b.gif",
							email: null,
							status: 1,
							deptName: "测试部门",
							roleNames: "访问游客",
							createTime: "2021-06-04"
						}
					],
					total: 2
				},
				msg: "一切ok"
			};
		}
	},

	{
		url: "/api/v1/users/:id/form",
		method: "get",
		response: ({ url }) => {
			const id = url.match(/\/api\/v1\/users\/(\d+)\/form/)[1];
			let formData = null;
			if (id == 2) {
				formData = {
					id: 2,
					username: "admin",
					nickname: "系统管理员",
					mobile: "17621210366",
					gender: 1,
					avatar:
						"https://oss.youlai.tech/youlai-boot/2023/05/16/811270ef31f548af9cffc026dfc3777b.gif",
					email: "",
					status: 1,
					deptId: 1,
					roleIds: [2]
				};
			} else if (id == 3) {
				formData = {
					id: 3,
					username: "test",
					nickname: "测试小用户",
					mobile: "17621210366",
					gender: 1,
					avatar:
						"https://oss.youlai.tech/youlai-boot/2023/05/16/811270ef31f548af9cffc026dfc3777b.gif",
					email: "youlaitech@163.com",
					status: 1,
					deptId: 3,
					roleIds: [3]
				};
			}

			return {
				code: "00000",
				data: formData,
				msg: "一切ok"
			};
		}
	}
] as MockMethod[];
